﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebUI.BL.ProductCategories;
using WebUI.DAL;


namespace WebUI.AdminSite.Product
{
    public partial class ProductCategory : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(!IsPostBack)
                BindData();
        }

        private void BindData()
        {
            var repository = new ProductCategories();
            var source = repository.GetProductCategoryByName(txtName.Text)
                .Select((x,i)=>new
                               {
                                   STT=i+1,
                                   Name=x.BreadCrum,
                                   Status=x.Status,
                                   DisplayOrder = x.DisplayOrder,
                                   No=x.CategoryNo
                               });
            grdProducts.DataSource = source;
            grdProducts.DataBind();

        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            BindData();
        }
    }
}